/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bda.mediatheque.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author samsung
 */
@Entity
@Table(name = "compte")
@NamedQueries({
    @NamedQuery(name = "Compte.findAll", query = "SELECT c FROM Compte c")})
public class Compte implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    @Column(name = "compteId")
    private Integer compteId;
    @Column(name = "solde")
    private Integer solde;
    @JoinColumn(name = "utilisateur", referencedColumnName = "idUtilisateur")
    @OneToOne(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
    private Utilisateur utilisateur;

    public Compte() {
    }

    public Compte(Integer compteId) {
        this.compteId = compteId;
    }

    public Integer getCompteId() {
        return compteId;
    }

    public void setCompteId(Integer compteId) {
        this.compteId = compteId;
    }

    public Integer getSolde() {
        return solde;
    }

    public void setSolde(Integer solde) {
        this.solde = solde;
    }

    public Utilisateur getUtilisateur() {
        return utilisateur;
    }

    public void setUtilisateur(Utilisateur utilisateur) {
        this.utilisateur = utilisateur;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (compteId != null ? compteId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Compte)) {
            return false;
        }
        Compte other = (Compte) object;
        if ((this.compteId == null && other.compteId != null) || (this.compteId != null && !this.compteId.equals(other.compteId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bda.mediatheque.dao.Compte[ compteId=" + compteId + " ]";
    }
    
}
